class Solution {
public:
    void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) {
        vector<int> tmp(m + n + 1);
        int i = 0, j = 0, p = 0;
        while(i < m && j < n){
            if(nums1[i] <= nums2[j])
                tmp[p++] = nums1[i++];
            else
                tmp[p++] = nums2[j++];
        }
        while(i < m)    tmp[p++] = nums1[i++];
        while(j < n)    tmp[p++] = nums2[j++];
        for(int t = 0; t < m + n; t++)    
            nums1[t] = tmp[t];
        return;
    }
};